<template>
	<el-container>
        <div style="width:100%;">
            <el-tabs tab-position="top">
                <el-tab-pane label="设备保养">
                    <el-header>
                            <div class="left-panel">
                            </div>
                            <div class="right-panel">
                                <div class="right-panel-search">
                                    <el-input v-model="payPassword" placeholder="请输入关键词查询"></el-input>
                                    <el-button type="primary" icon="el-icon-plus" @click="add">查询</el-button>
                                </div>
                            </div>
                        </el-header>
                    <el-container>
                        <el-main class="nopadding">
                            <scTable ref="table" :data="data" @selection-change="selectionChange" stripe remoteSort remoteFilter border height='700'>
                                <el-table-column type="selection"  align="center" width="50"></el-table-column>
                                <el-table-column label="保养计划" prop="name" align="center"></el-table-column>
                                <el-table-column label="任务日期" prop="name" align="center"></el-table-column>
                                <el-table-column label="任务时间段" prop="name" align="center"></el-table-column>
                                <el-table-column label="执行人/执行部门" prop="name" align="center"></el-table-column>
                                <el-table-column label="状态" prop="name" align="center"></el-table-column>
                                <el-table-column label="设备" prop="name" align="center"></el-table-column>
                                <el-table-column label="设备数" prop="name" align="center"></el-table-column>
                            </scTable>
                        </el-main>
                    </el-container>
                </el-tab-pane>
                <el-tab-pane label="客户产品保养">
                    <el-container>
                        <el-header>
                            <div class="left-panel">
                            </div>
                            <div class="right-panel">
                                <div class="right-panel-search">
                                    <el-input v-model="payPassword" placeholder="请输入关键词查询"></el-input>
                                    <el-button type="primary" icon="el-icon-plus" @click="add">查询</el-button>
                                </div>
                            </div>
                        </el-header>
                        <el-main class="nopadding">
                            <scTable ref="table" :data="data" @selection-change="selectionChange" stripe remoteSort remoteFilter border height='700'>
                                <el-table-column type="selection"  align="center" width="50"></el-table-column>
                                <el-table-column label="保养计划" prop="name" align="center"></el-table-column>
                                <el-table-column label="任务日期" prop="name" align="center"></el-table-column>
                                <el-table-column label="任务时间段" prop="name" align="center"></el-table-column>
                                <el-table-column label="执行人/执行部门" prop="name" align="center"></el-table-column>
                                <el-table-column label="状态" prop="name" align="center"></el-table-column>
                                <el-table-column label="产品" prop="name" align="center"></el-table-column>
                                <el-table-column label="产品数" prop="name" align="center"></el-table-column>
                            </scTable>
                        </el-main>
                    </el-container>
                </el-tab-pane>
            </el-tabs>
        </div>
	<save-dialog v-if="dialog.save" ref="saveDialog" @success="handleSuccess" @closed="dialog.save = false" draggable></save-dialog>
	</el-container>
</template>

<script>
import saveDialog from './save'
export default {
	name: 'user',
	components: {
		saveDialog
	},
	data() {
		return {
			dialog: {
				save: false,
			},
			groupFilterText: '',
			group: [],
			apiObj: this.$API.system.menu.list,
			selection: [],
			search: {
				title: null,
				cid: null,
			},
			//所需数据选项
			cates: [],
            data:[
                {id:0,name:'ceshi'},
                {id:1,name:'ceshi'},
            ]
		}
	},
	watch: {
		groupFilterText(val) {
			this.$refs.group.filter(val);
		}
	},
	mounted() {
	},
	methods: {
		//添加
		add() {
			this.dialog.save = true
			this.$nextTick(() => {
				this.$refs.saveDialog.open('add')
			})
		},
        table_detail(row){
            this.$router.push({
			path: '/device/list/detail',
            query:{
                id:row.id
            }
		})
        },
		//编辑
		table_edit(row) {
            console.log('row :>> ', row);
			this.dialog.save = true
			this.$nextTick(() => {
				this.$refs.saveDialog.open('edit').setData(row)
			})
		},
        goLocation(){
            this.$router.push({
                path: 'storeroomLocation',
            })
        },
		//删除
		async table_del(row, index) {
			var reqData = { id: row.id }
			var res = await this.$API.goods.getGoods.delete.post(reqData);
			if (res.code == 1) {
				//这里选择刷新整个表格 OR 插入/编辑现有表格数据
				this.$refs.table.tableData.splice(index, 1);
				this.$message.success("删除成功")
			} else {
				this.$alert(res.message, "提示", { type: 'error' })
			}
		},
		//搜索
		upsearch() {
			this.$refs.table.upData(this.search)
		},
		//本地更新数据
		handleSuccess(data, mode) {
			if (mode == 'add') {
				this.$refs.table.refresh()
			} else if (mode == 'edit') {
				this.$refs.table.refresh()
			} else if (mode == 'set') {
				this.$refs.table.refresh()
			}
            this.printArr = ''
		},
        selectionChange(selection) {
			this.selection = selection;
		},
	}
}
</script>

<style>
.search-input {
	width: auto;
	font-size: 14px;
}
.shopInfo{
    display: flex;
    align-items: center;
}
.img{
    width: 100px;
    height: 100px;
    margin-right: 5px;
}
</style>
